package m202405.d13;

/**
 * @@author: 爱做梦的锤子
 * @date: 2024/5/13 12:36
 */
public class Q101 {
    public boolean isSymmetric(TreeNode root) {
        return travel(root.left, root.right);
    }

    public boolean travel(TreeNode left, TreeNode right) {
        if ((left == null && right != null) || (left != null && right == null)) {
            return false;
        }
        if (left == null && right == null) {
            return true;
        }
        if (left.val != right.val) {
            return false;
        }
        return travel(left.left, right.right) && travel(left.right, right.left);
    }
}
